def convert_currency(amount, currency, exchange_rate):
    if currency.lower() == 'rmb':
        return amount / exchange_rate
    elif currency.lower() == 'usd':
        return amount * exchange_rate
    else:
        return "Unknown currency type."

def main():
    exchange_rate = 7  # 中美汇率设定为7
    while True:
        try:
            amount = float(input("请输入金额: "))
            currency = input("请输入货币类型（人民币: RMB，美元: USD）: ")
            converted_amount = convert_currency(amount, currency, exchange_rate)
            if isinstance(converted_amount, str):
                print(converted_amount)
            else:
                print(f"转换后的金额为: {converted_amount:.2f}")
        except ValueError:
            print("输入的金额不是有效的数字，请重新输入。")
        except Exception as e:
            print(f"发生了一个错误: {e}")
        finally:
            continue_input = input("是否继续? (y/n): ").lower()
            if continue_input == 'q' or continue_input == 'n':
                break

    print("程序结束，感谢使用。")

if __name__ == "__main__":
    main()